package com.maweirdos.ai.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * ChatClient配置类
 * 基于ChatModel创建ChatClient
 */
@Configuration
public class ChatClientConfig {

    @Autowired
    private ChatModel dashscopeChatModel;

    /**
     * 配置ChatClient
     * 使用已经自动配置的ChatModel创建ChatClient
     */
    @Bean
    @Primary
    public ChatClient chatClient() {
        // 在Spring AI 1.0.0.2中，ChatClient.builder()需要传入ChatModel参数
        return ChatClient.builder(dashscopeChatModel).build();
    }
} 